{% extends 'app_doc/manage_base.html' %}
{% load static %}
{% block title %}文集设置{% endblock %}
{% block content %}
    <div class="layui-row" style="margin-bottom: 10px;padding-left:15px;">
        <span class="layui-breadcrumb" lay-separator=">">
          <a href="{% url 'manage_project' %}">文集管理</a>
          <a href="{% url 'modify_project' %}?pro_id={{pro.id}}">文集设置</a>
          <a><cite>转让文集</cite></a>
        </span>
    </div>
    <div class="layui-card-header" style="margin-bottom: 10px;">
        <div class="layui-row">
            <span style="font-size:18px;">转让文集：{{pro.name}}
            </span>
        </div>
        <div class="layui-row">
            <div class="layui-form">
                <select name="user-select" id="user-select" lay-verify="" lay-search>
                    <option value="">选择用户，可搜索</option>
                    {% for user in user_list %}
                    <option value="{{user.username}}">{{user.first_name}}({{user.username}})</option>
                    {% endfor %}
                  </select>
            </div>
        </div>
        <div class="layui-row" style="margin-top: 5px;">
            <button class="layui-btn layui-btn-normal" id="transfer-project"><i class="layui-icon layui-icon-transfer"></i> 转让文集的管理权限及文档</button>
        </div>
    </div>
{% endblock %}
{% block custom_script %}
<script src="{% static '/tagsInput/tagsinput.js' %}" type="text/javascript" charset="utf-8"></script>
<script>
    $.ajaxSetup({
            data: {csrfmiddlewaretoken: '{{ csrf_token }}' },
        });
    var form = layui.form;
    // 转让文集
    transferProject = function(){
        layer.load(1);
        data = {
            'username':$("#user-select").val(),
        }
        $.post("{% url 'manage_pro_transfer' pro.id %}",data,function(r){
            layer.closeAll('loading'); //关闭loading
            if(r.status){
                //转让成功
                layer.msg('转让成功，即将返回文集列表……',function(){
                    window.location.href = "{% url 'manage_project' %}"
                })
                //layer.close(index)
            }else{
                //转让失败，提示
                console.log(r)
                layer.msg(r.data)
            }
        })
    }
    $("#transfer-project").click(function(){
        transferProject();
    })
</script>
{% endblock %}